<?php
/**
 * Created by PhpStorm.
 * User: 明哲
 * Date: 2016/6/3
 * Time: 14:14
 */
include('../../config.php');

$action = $_GET['action'];
$id = $_GET['id'];

switch ($action) {
    default:
        $row = $mysql->query("select *  from `category` where `category_id`='{$id}'");
        if($row){
            echo json_encode($row[0],true);
        }else{
            echo 0;
        };
        break;
    case 'del' :
        $rows = $mysql->query("delete from `category` where `category_id`='{$id}'");
        echo 1;
        break;
    case 'update' :
        $category_id = $_GET['category_id'];
        $category_name= $_GET['category_name'];
        $category_img = $_GET['category_img'];
        $rows = $mysql->query("update `category` set `category_name`='{$category_name}',`category_img`='{$category_img}' where `category_id`='{$category_id}'");
        if(!$rows){
            echo 1;
        }else{
            echo 0;
        }
        break;
}